using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Network;
using MicroMsg.Protocol;
using System;
namespace MicroMsg.Scene
{
	public class NetSceneGetUserName : NetSceneBaseEx<GetUserNameRequest, GetUserNameResponse, GetUserNameRequest.Builder>
	{
		private const string TAG = "NetSceneGetUserName";
		public static string mRegNickName;
		public static string mRepUserName;
		public void doScene(string nickName)
		{
			base.beginBuilder();
			NetSceneGetUserName.mRegNickName = nickName;
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(33);
			this.mBuilder.Pwd = Util.NullAsNil(NetSceneAuth.mAuthUserPwdMD5);
			this.mBuilder.NickName = Util.NullAsNil(nickName);
			this.mBuilder.BindUin = (uint)Util.stringToInt(NetSceneAuth.mAuthUserName);
			this.mBuilder.Ticket = Util.NullAsNil(SessionPackMgr.mAuthTicket1);
			SessionPackMgr.getAccount().setNickname(nickName);
			this.mSessionPack.mCmdID = 33;
			base.endBuilder();
		}
		protected override void onSuccess(GetUserNameRequest request, GetUserNameResponse response)
		{
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret != RetConst.MM_OK)
			{
				EventCenter.postEvent(EventConst.ON_NETSCENE_FILLUSERNAME_ERR, ret, null);
				return;
			}
			NetSceneGetUserName.mRepUserName = response.UserName;
			EventCenter.postEvent(EventConst.ON_NETSCENE_FILLUSERNAME_SUCCESS, null, null);
		}
		protected override void onFailed(GetUserNameRequest request, GetUserNameResponse response)
		{
			EventCenter.postEvent(EventConst.ON_NETSCENE_FILLUSERNAME_ERR, -800000, null);
		}
	}
}
